#ifndef STATUS_H
#define STATUS_H

#include <QMetaType>
#include <QString>

#include "statustypegroup.h"
#include "statustype.h"

/**
 * This class describes current status of any user.
 * Status contains two values - status type and description.
 * Statuses can be ordered using StatusType enum (smaller value means greater availability).
 */
class Status
{
public:
    /**
     * Creates new status with given type and description.
     */
    Status(StatusType statusType = StatusTypeOffline, const QString &description = QString());
    Status(const Status &copyMe);
    ~Status();

    /**
     * Returns this status type.
     */
    inline StatusType type() const {
        return m_type;
    }

    /**
     * Updates this status type. Values of displayName and group are also updated.
     */
    void setType(StatusType type);

    /**
     * Returns this status type group. This value depends only on current status type.
     */
    inline StatusTypeGroup group() const {
        return m_group;
    }

    /**
     * Returns this status display name. This value depends only on current status type.
     */
    inline const QString & displayName() const {
        return m_displayName;
    }

    /**
     * Returns this status description.
     */
    inline const QString & description() const {
        return m_description;
    }

    /**
     * Updates this status description.
     */
    inline void setDescription(const QString &description) {
        m_description = description;
    }

    /**
     * Returns true if this status description is not empty.
     */
    bool hasDescription() const;

    /**
     * Returns true if this status if not connected (offline).
     */
    bool isDisconnected() const;

    /**
     * This method compares two statuses. Status which is more available is considered 'less', so it returns
     * true when left status is more available than right one.
     */
    bool operator < (const Status &compare) const;

    /**
     * This method compares two statuses. Statuses are equal when its types and description are equal.
     */
    bool operator == (const Status &compare) const;

    /**
     * This method compares two statuses. Statuses are not equal when its types or description are not equal.
     */
    bool operator != (const Status &compare) const;

private:
    StatusType m_type;
    StatusTypeGroup m_group;
    QString m_description;
    QString m_displayName;
};

Q_DECLARE_METATYPE(Status)

#endif // STATUS_H
